
<!DOCTYPE html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>EOIP登录</title>
    <!-- <link href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> -->
    <link href="../css/bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="../css/global.css" rel="stylesheet">
</head>

<body>
    <!--1.0 narbar -->
    <div   class="fixedNavbar">
       <#include "../navbar.html">
	</div>

     <div class="container">
        <div id="loginbox" style="margin-top:50px;" class="mainbox col-md-5 col-md-offset-4 col-sm-8 col-sm-offset-2">
            <div class="panel panel-info">
                <div class="panel-heading">
                    <div class="panel-title">登录</div>
                    <div style="float:right; font-size: 80%; position: relative; top:-18px"><a href="#">忘记密码?</a>
                    </div>
                </div>

                <div style="padding-top:30px" class="panel-body">
                    <form id="loginForm" class="form-horizontal" role="form">
                        <div style="margin-bottom:5px" class="input-group">
                            <span class="input-group-addon">
                                <i class="glyphicon glyphicon-home"></i>
                            </span>
                            <input id="username" type="text" class="form-control" name="username" value="" placeholder="手机/邮箱">
                        </div>
                        <span class="help-block" style="height:16px;margin-bottom:15px;color:red;"></span>
                        <div style="margin-bottom:5px" class="input-group">
                            <span class="input-group-addon">
                                <i class="glyphicon glyphicon-lock"></i>
                            </span>
                            <input id="password" type="password" class="form-control" name="password" placeholder="密码">
                        </div>
                        <span class="help-block" style="height:16px;margin-bottom:15px;color:red;"></span>
                        <div style="margin-top:10px" class="form-group">
                            <div class="col-sm-12 controls">
                                <button id="btn-login" type="submit" class="btn btn-success">  马上登录  </button>
                                <span id="hint" class="btn" style="color:red;display:none;">
                               	 	用户名或密码错误
                            	</span>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <script src="../js/bootstrap/jquery-1.11.1.min.js"></script>
    <script src="../js/jquery.validate.js"></script>
    <script src="../js/bootstrap/bootstrap.min.js"></script>
	<script src="../js/common.js"></script>
	<script src="../js/util.js"></script>
	<script src="../js/sha1.js"></script>
    <script>
        $(document).ready(function () {
        	$("#loginForm").validate({
				rules: {
					username: {
						required: true
					},
					password: {
						required: true
					},
				},
				messages: {
					username: {
						required: "用户名不能为空"
					},
					password: {
						required: "密码不能为空"
					},
				},
				submitHandler : function() {
/* 					debugger; */
					var username = $("#username").val();
					var usernameType = "";
					var isEmail = util.isEmail(username);
					if(isEmail) {
						usernameType = "EMAIL";
					}
					
					var isPhoneNum = util.isPhoneNum(username);
					if(isPhoneNum) {
						usernameType = "MOBILE";
					}
					var password = hex_sha1('' + $('#password').val());
					
					var url = "/eoip/web/doLogin";
					var params = { 
									username : username,
									usernameType : usernameType,
									password:hex_sha1('' + $('#password').val()),
								 };
					common.post(url, params, function (data) {
                        $("#hint").text('').show();
                        var data = jQuery.parseJSON(data);
                        if (data.code == "1") {
                            $("#hint").text('登录成功...').show();
                            //alert('登录成功!');
                            location.href = '/eoip/web/online_box_query';
                        } else {
                            $("#hint").text(data.info).show();
                        }//end if
                    });//end common post
				}
			});
        });
    </script>
</body>
</html>
